package com.zte.claa.inficombo.csa.app.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component  
@ConfigurationProperties(prefix="csa.mqtt.para") 
public class MQTTParaConfig {
	// switch=on: open; off: close
	public static final String SWITCH_ON = "on";
	public static final String SWITCH_OFF = "off"; 
	public static final String PROJECT_ALL = "all";
	public static final String CLIENT_ID_PREFIX = "inficombocsa";

	private String switcher = SWITCH_OFF;
	private String protocol = "tcp";
	private String svrip = "localhost";
	private int svrport = 61613;
	private String clientidprefix = CLIENT_ID_PREFIX;
	private String username = "admin";
	private String password = "Zte_claa@2017";
	private String charset = "UTF-8";
	private int conntimeoutsec = 10;
	private int keepaliveintervalsec = 20;
	private int queuesize = 1000;
	private int breakcheckintervalsec = 20;
	
	public MQTTParaConfig(){
		
	}
	
	public MQTTParaConfig clone(){
		MQTTParaConfig c = new MQTTParaConfig();
		c.setSwitcher(switcher);
		c.setProtocol(protocol); 
		c.setSvrip(svrip); 
		c.setSvrport(svrport); 
		c.setClientidprefix(clientidprefix);
		c.setUsername(username); 
		c.setPassword(password);
		c.setCharset(charset); 
		c.setConntimeoutsec(conntimeoutsec); 
		c.setKeepaliveintervalsec(keepaliveintervalsec);
		c.setQueuesize(queuesize); 
		c.setBreakcheckintervalsec(breakcheckintervalsec); 
		return c;
	}

	public String getSwitcher() {
		return switcher;
	}

	public void setSwitcher(String switcher) {
		this.switcher = switcher;
	}

	public String getProtocol() {
		return protocol;
	}

	public void setProtocol(String protocol) {
		this.protocol = protocol;
	}

	public String getSvrip() {
		return svrip;
	}

	public void setSvrip(String svrip) {
		this.svrip = svrip;
	}

	public int getSvrport() {
		return svrport;
	}

	public void setSvrport(int svrport) {
		this.svrport = svrport;
	}

	public String getClientidprefix() {
		return clientidprefix;
	}

	public void setClientidprefix(String clientidprefix) {
		this.clientidprefix = clientidprefix;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getCharset() {
		return charset;
	}

	public void setCharset(String charset) {
		this.charset = charset;
	}

	public int getConntimeoutsec() {
		return conntimeoutsec;
	}

	public void setConntimeoutsec(int conntimeoutsec) {
		this.conntimeoutsec = conntimeoutsec;
	}

	public int getKeepaliveintervalsec() {
		return keepaliveintervalsec;
	}

	public void setKeepaliveintervalsec(int keepaliveintervalsec) {
		this.keepaliveintervalsec = keepaliveintervalsec;
	}

	public int getQueuesize() {
		return queuesize;
	}

	public void setQueuesize(int queuesize) {
		this.queuesize = queuesize;
	}

	public int getBreakcheckintervalsec() {
		return breakcheckintervalsec;
	}

	public void setBreakcheckintervalsec(int breakcheckintervalsec) {
		this.breakcheckintervalsec = breakcheckintervalsec;
	}
	
	public boolean checkSwitchIsOn(){
		return SWITCH_ON.equalsIgnoreCase(this.switcher);
	}
}
